package org.example.test;

/**
 * @author: lynn
 * @Descript: 打印字符串的所有子序列
 * @date: 2021/3/4 22:21
 * @version: 1.0
 */
public class PrintAllSubChars {
    public static void main(String[] args) {
        printAllSubSequences("abcd", 0, "");
    }

    public static void printAllSubSequences(String str,int index,String res) {
        //base case ： 当本级子过程来到的位置到达串末尾，则直接打印
        if(index == str.length()) {
            System.out.println(res);
            return;
        }
        //决策是否要index位置上的字符
        printAllSubSequences(str, index+1, res+str.charAt(index));
        printAllSubSequences(str, index+1, res);
    }
}
